const {query} = require('../db/db')

const artcle = {
  async getList(pageNum = 1, pageSize = 10) {
      //limit start:开始的行数 size：显示多少行 
      // const sql = 'select * from ag_artclelist where is_del=0 order by create_time desc limit ?,? '
      const sql = 'select * from ag_artclelist where order by create_time desc limit ?,?'
      //0, 8 //8, 8, //,8
      // (pageNum - 1) * pageSize 
      //0,10 ==> 10, 10==>20, 10
      const start = (pageNum - 1) * pageSize
      const results = await query(sql, [start, pageSize])
      return results;
  },
  async count() {
    const sql = 'select count(*) as count from ag_artclelist'
    const results = await query(sql)
    return results[0]
  }
}

module.exports = {artcle}